package com.lejin.usercenter.controller;

import com.lejin.interceptor.InterceptorConfig;
import com.lejin.interceptor.UserInfoInterceptor;
import com.lejin.usercenter.entity.UserBaseinfo;
import com.lejin.usercenter.service.IUserBaseinfoService;
import com.lejin.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luminghua
 * @since 2022-04-20
 */
@CrossOrigin
@RestController
@RequestMapping("/usercenter/user-baseinfo")
public class UserBaseinfoController {
    @Autowired
    private UserInfoInterceptor userInfoInterceptor;

    @Autowired
    private IUserBaseinfoService iUserBaseinfoService;


    //添加用户信息

    @PostMapping("add")
    public ResultVO add(@RequestBody(required = false) UserBaseinfo userBaseinfo){
        System.out.println("进来了");
      return iUserBaseinfoService.addUserInfo(userBaseinfo);

    }

    //查询用户信息
    @RequestMapping("list")
    public ResultVO list(){


        ResultVO userInfo = iUserBaseinfoService.findUserInfo(userInfoInterceptor.getThreadLocal().get());
        return userInfo;

    }

}
